package com.aim.common.service;

import com.aim.common.util.JdbcTemplateUtil;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @AUTO
 * @Author AIM
 * @DATE 2019/6/3
 */
@Service("dict")
public class DictService {

    @Resource
    private JdbcTemplate jdbcTemplate;

    /**
     * 根据字典类型查询字典数据信息
     *
     * @param dictType 字典类型
     * @return 参数键值
     */
    public List<Map<String, Object>> getType(String dictType) {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT s.`DICT_ID`,s.`NAME`,s.`CODE`,s.`SIGN` FROM `sys_dict` s ");
        sb.append(" INNER JOIN `sys_dict` d ON s.`PID` = d.`DICT_ID` ");
        sb.append(" WHERE d.`CODE`=? ").append(" ORDER BY s.`SORT` ASC");
        List<Map<String, Object>> maps = JdbcTemplateUtil.queryForListMap(jdbcTemplate, sb.toString(), dictType);
        return maps;
    }
}
